package com.ego.controller;

import com.ego.dao.OrderDao;
import com.ego.dao.impl.OrderDaoImpl;
import com.ego.vo.OrderItemVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 袁梦达 2019012364
 */
@WebServlet("/OrderServlet")
public class OrderServlet extends HttpServlet {

    private OrderDao orderDao = new OrderDaoImpl();

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String userNumber = (String) getServletContext().getAttribute("userNumber");

        if(userNumber == null){
            //未登录
            response.getWriter().print(false);
        }else {
            boolean result = orderDao.createOrder(userNumber);
            response.getWriter().print(result);
        }
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
